put XScrollBox(4,"Choose Font for Stuff List:",card field "fonts", "Help") into f
if f is "Help" then
doHelp
exit mouseUp
else if f is empty or f is "cancel" then exit mouseUp
else
put item 2 of f into f
get XScrollBoxF("c","Choose some stuff:",card field "scroller","",f)
if it is empty then exit mouseUp
go this card
answer "Selection was:"&&it
end if
end mouseUp
on doHelp
put "Choose a font to use in displaying the test field."
end doHelp
-- part contents for card part 5
----- text -----
XScrollBoxF version 2.4
Roger Brown
XScrollBoxF is a version of XScrollBox that allows the selection list to be presented in a font other than the system font.
For example, this is being used to create an index to Greek literary references using a Greek font. All specifications are the same as for XScrollBox except for an additional input parameter: the name of the font to use. The named font must be available from the system or the stack and the font size will always be 12.
The return value has two items: the number of the selection and the text of the selection. These are separated by commas as in normal HyperCard format.
Selection can be made by :
1. double-clicking on a line.
2. single-clicking on a line, then pressing the OK button.
3. single-clicking on a line, then pressing the Return key.
4. typing the first letter(s) of a selection, then doing 1,2, or 3.
(Note: type selection assumes that the lines are ordered
alphabetically)
5. scrolling with up and down arrow keys, then doing 1,2 or 3.
If the Cancel button is pressed, the string "Cancel" is returned.
It requires that the DITL and DLOG resources (1346) packaged
with it are in the stack.
The dialog is centered on the screen and sized to hold the width of the longest line and/or the prompt line, whichever is widest. It will not overrun the width of a Mac+ screen.
INVOKING XScrollBoxF
get XScrollBoxF(first,prompt,container,userButton,font)
where first is a default selection in the list - either a number or
a text string (0 if none).
prompt is a string to prompt the user. This appears at the
top of the dialog box.
container is any hypercard container (field, variable),
presumed to be multi-lined.
UserButton is the name for an optional author specified
button. If this button is pressed, its name is returned
further processing by the script.
Font is the name of the font to use.
EXAMPLE
ex. get XScrollBoxF(1,"Choose:",card field 1,"Help","cartoon")
if OK is pressed, returns : 1,text of line 1 of card field 1
REVISION HISTORY
1.1 center dialog box on any size screen
1.2 - add selection scrolling by typing and by cursor keys
1.3 - add text of chosen item to return value
1.4 - 3/2/88 add optional user button
1.6 - fixed some selection by typing problems
1.7 - LSC 3.0 compatible. Fixed problem of a bomb if the font is
not specified.
2.0 - 9/9/89 SuperCard compatible, fixed bugs in typing-selection,
and userButton string handling. First item is selected if there
is no default and the user presses a cursor arrow key. One
source for all 3 versions, control version with compiler
variables. Compiles under THINK C Γäó 4.0.
2.1 - 2/21/90 Puch of cancel button now returns "Cancel" string.
Fixed some bugs in allocatin and use of return handle.